import Constants from "../libs/Constants";
import GameData from "../libs/GameData";
import { GameEvent } from "../libs/GameEvent";
import Helper from "../libs/HelperMgr";

const { ccclass, property } = cc._decorator;

@ccclass
export default class UIUnlockLevel extends cc.Component {



    start() {

    }

    onVideo() {
        GameData.instance.gameMaxStage++;
        this.onClose();

    }

    onDiamond() {
        if (GameData.instance.playGold >= 300) {
            GameData.instance.gameMaxStage++;
            GameData.instance.playGold -= 300;
        }else{
            Helper.showTip("钻石不足");
        }
        this.onClose();

    }


    onClose() {
        GameEvent.emit(Constants.StageEvent.RefreshLevel)
        GameData.instance.saveData();
        this.node.removeFromParent();
        this.node.destroy();
    }

}
